package com.adong.tv.ui.presenter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.leanback.widget.Presenter;

import com.adong.tv.R;
import com.adong.tv.model.ApiSource;

/**
 * API源呈现器
 */
public class ApiPresenter extends Presenter {
    
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_api, parent, false);
        return new ViewHolder(view);
    }
    
    @Override
    public void onBindViewHolder(ViewHolder viewHolder, Object item) {
        if (item instanceof ApiSource) {
            ApiSource apiSource = (ApiSource) item;
            TextView textView = (TextView) viewHolder.view;
            textView.setText(apiSource.getDesc());
        }
    }
    
    @Override
    public void onUnbindViewHolder(ViewHolder viewHolder) {
        // 无需清理
    }
} 